package viewModel;

import static org.junit.Assert.*;

import org.junit.Test;

import de.dhbw.horb.inf2013.vierFarbenProblem.model.datatypes.VertexNotSetException;

public class generateSquares {

	@Test
	public void test3x3() throws VertexNotSetException {
		TestModel model = new TestModel();
		TestViewModel viewModel = new TestViewModel(model);
		
		viewModel.generateHexagons(3, 3, 1, 1);
		boolean correctHexagons= true;
		
		for (int i=1; i<= 9; i++) {
			
			if (!model.vertexExist(i)) {
				correctHexagons = false;
			}
		}
		
		
		if (!model.areNeighbors(1, 2)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(1, 4)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(2, 5)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(2, 3)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(3, 6)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(4, 5)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(4, 7)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(5, 8)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(5, 6)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(6, 9)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(7, 8)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(8, 9)) {
			correctHexagons = false;
		}
		
		assertEquals(true, correctHexagons);
		
	}
	@Test
	public void test2x2() throws VertexNotSetException {
		TestModel model = new TestModel();
		TestViewModel viewModel = new TestViewModel(model);
		
		viewModel.generateHexagons(2, 2, 1, 1);
		boolean correctHexagons= true;
		
		for (int i=1; i<= 4; i++) {
			
			if (!model.vertexExist(i)) {
				correctHexagons = false;
			}
		}
		
		
		if (!model.areNeighbors(1, 2)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(1, 3)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(2, 4)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(3, 4)) {
			correctHexagons = false;
		}
		
		
		
		assertEquals(true, correctHexagons);
		
	}
	@Test
	public void testBidirectional() throws VertexNotSetException {
		TestModel model = new TestModel();
		TestViewModel viewModel = new TestViewModel(model);
		
		viewModel.generateHexagons(1, 2, 1, 1);
		boolean correctHexagons= true;
		
		for (int i=1; i<= 2; i++) {
			
			if (!model.vertexExist(i)) {
				correctHexagons = false;
			}
		}
		
		
		if (!model.areNeighbors(1, 2)) {
			correctHexagons = false;
		}
		if (!model.areNeighbors(2, 1)) {
			correctHexagons = false;
		}
		
		
		
		assertEquals(true, correctHexagons);
		
	}

}
